extends Control

var buttons = []
var timer = 0.0

signal open_shop

func _ready():
	buttons = $VBoxContainer.get_children()
	$VBoxContainer/open_shop.connect("pressed", self, "on_open_shop")
	$VBoxContainer/close.connect("pressed", self, "on_close")

func _process(delta):
	if !self.visible: return
	timer += delta
	for b in buttons:
		if b.has_focus():
			b.rect_rotation = sin(timer*3)*5
		else:
			b.rect_rotation = 0

func open():
	$VBoxContainer/open_shop.grab_focus()
	$AnimationPlayer.play("open")
	self.visible = true
	G.in_ui = true
	

func on_open_shop():
	self.emit_signal("open_shop")
	self.visible = false

func on_close():
	G.in_ui = false
	self.visible = false
